<?php

declare (strict_types=1);
namespace App\Model;

use App\Traits\ModelLabelTrait;
use Hyperf\Database\Model\SoftDeletes;
use Hyperf\DbConnection\Model\Model;
/**
 * @property int $id
 * @property int $district_id
 * @property int $street_id
 * @property string $name
 * @property \Carbon\Carbon $created_at
 * @property \Carbon\Carbon $updated_at
 * @property string $deleted_at
 */
class Community extends Model
{
    use ModelLabelTrait,SoftDeletes;
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'community';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'district_id',
        'street_id',
        'name',
        'type'
    ];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'int', 'district_id' => 'integer', 'street_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];


    const TYPE_ONE=1;
    const TYPE_TWO=2;

    const TYPE_LABELS=[
        self::TYPE_ONE => '社区',
        self::TYPE_TWO => '文明实践站'
    ];

    public function district(){
        return $this->belongsTo(Area::class,'district_id','id');
    }

    public function street(){
        return $this->belongsTo(Street::class,'street_id','id');
    }
}